package com.example.demo.handler;

import com.example.demo.util.R;
import com.example.demo.util.ResultUtil;
import org.apache.shiro.authz.AuthorizationException;
import org.apache.shiro.authz.UnauthorizedException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;

/**
 * fileName:CtrlExceptionHandler
 * description:全局处理异常
 * author: LJV
 * createTime:2022/4/12 14:45
 * version:1.0.0
 */
@ControllerAdvice
public class CtrlExceptionHandler {

    private static Logger logger = LoggerFactory.getLogger(CtrlExceptionHandler.class);

    @ResponseStatus()
    @ExceptionHandler(Exception.class)
    public ResponseEntity<R<String>> handleException(Exception e) {
        logger.debug(e.getMessage());
        return ResultUtil.failMsg(e.getMessage());
    }

}
